package com.example.demo.fruits.factory;

import com.example.demo.fruits.Apple;
import com.example.demo.fruits.Fruits;
import com.example.demo.fruits.Mango;
import com.example.demo.fruits.Strawberry;
import lombok.extern.slf4j.Slf4j;


@Slf4j
public class FruitFactory {
    public static Fruits createFruits(String name){
        Fruits fruits=null;
        switch (name){
            case "苹果": fruits=new Apple();
            break;
            case "芒果": fruits=new Mango();
            break;
            case "草莓": fruits=new Strawberry();
            break;
            default:log.info("未知类型水果");
        }

        return fruits;
    }
}
